const fs = require('fs')


//获取当前目录的所有文件循环注册路由
const useRoutes = app => {
  fs.readdirSync(__dirname).forEach(file => {
    if(file !== 'index.js'){
      const router = require(`./${file}`)
      app.use(router.routes())
      app.use(router.allowedMethods())
    }
  })
}

module.exports = useRoutes